<?php
(!defined('IN_TOA') || !defined('IN_ADMIN')) && exit('Access Denied!');
/*
	[天生创想] (C)2008-2011 515158 Inc.
	This is NOT a freeware, use is subject to license terms
    URL:http://www.515158.com/
*/
get_config_keytable("bbs_add");
empty($do) && $do = 'list';
if ($do == 'list') {
	include_once('template/add.php');

} elseif ($do == 'save') {
	
	$savetype = getGP('savetype','P');
	$bbsclass = getGP('bbsclass','P');
	$title = getGP('title','P');
	$author = getGP('author','P');
	$origin = getGP('origin','P');
	$content = getGP('content','P');
	$issuedate = get_date('Y-m-d H:i:s',PHP_TIME);
	$readnum = 0;
	$uid = $_USER->id;
	$bbstyle = $db->fetch_one_array("SELECT * FROM ".DB_TABLEPRE."bbsclass  WHERE id = '$bbsclass'");
	if($bbstyle["type"]=='1'){
	$type =2;
	}else{
	$type =1;
	}
	
	
	//主表信息
	$bbs = array(
		'bbsclass' => $bbsclass,
		'title' => $title,
		'author' => $author,
		'origin' => $origin,
		'content' => $content,
		'issuedate' => $issuedate,
		'readnum' => $readnum,
		'type' => $type,
		'uid' => $uid
	);
	//写入主表信息
	insert_db('bbs',$bbs);
	$id=$db->insert_id();
	$content=$bbsclass.get_inc_log(1).$title.get_inc_log(1).$author.get_inc_log(1).$origin.get_inc_log(1).$content.get_inc_log(1).$issuedate.get_inc_log(1).$readnum.get_inc_log(1).$type.get_inc_log(1).$uid;
	$title='发布贴子';
	get_oa_log_dbadd($id,$content,$title,30,$_USER->id);
    goto_page('admin.php?ac=index&fileurl=bbs');

}
function get_inc_bbs_type($selid = 0) {
	global $db;
	$html = '';
	$sql = "SELECT id,name FROM ".DB_TABLEPRE."bbsclass";
	$query = $db->query($sql);
	while ($row = $db->fetch_array($query)) {
		$selstr = $row['id'] == $selid ? 'selected="selected"' : '';
		$html .= '<option value="'.$row['id'].'" '.$selstr.' >'.$row['name'].'</option>';
	}
	return $html;
}
?>